home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / TAWUG / TAWUG Disk No. 56 (SHK) / TAWUG56.shk / DISK.COMMANDS (.txt) < prev    next >
AppleWorks Document  |  1987-07-01  |  4KB  |  93 lines

  1. O=====|====|====|====|====|====|====|====|====|====|====|====|====|====|====|===
  2. USING DISK DRIVE COMMANDS IN MACHINE LANGUAGE
  3. BY STEPHEN KILLOUGH
  4. From  Apple Computer Enjoyment Society 
  5.       Fort Lauderdale, Florida"
  6.       Vol 3 No 3,  May/June 1981
  7. ;    Sometimes when programming in assembly language, it is D
  8. Bnecessary to use one of the regular disk commands, such as BLOAD, D
  9. BBSAVE, etc.  The usual procedure is to have an accompanying BASIC B
  10. @program handle the disk commands and call the machine routine.  <
  11. :Sometimes it would be more convenient, though, if it were D
  12. Bpossible to use the disk without switching back and forth between 2
  13. languages.  Here is a method of doing just that.
  14. B    Basically, the method of controlling the disk by printing the @
  15. >command with a CTRL-D in front of it is valid even in machine D
  16. Blanguage, providing the printing is done by the COUT routine (see C
  17. Apages 30 and 61 of the APPLE ][ REFERENCE MANUAL).  Your machine <
  18. :language routine should send out, one by one via the COUT A
  19. ?routine, the ConTRoL-D, and command characters, and the return <
  20. character.  An example of a machine language routine that +
  21. would perform a "CATALOG" is shown below:
  22.      LDA  #$84      ;code for CTRL-D#
  23.      JSR  $FDED     ;COUT address!
  24.      LDA  #$C3      ;code for C
  25.      JSR  $FDED     !
  26.      LDA  #$C1      ;code for A
  27.      JSR  $FDED     !
  28.      LDA  #$D4      ;code for T
  29.      JSR  $FDED     !
  30.      LDA  #$C1      ;code for A
  31.      JSR  $FDED     !
  32.      LDA  #$CC      ;code for L
  33.      JSR  $FDED     !
  34.      LDA  #$CF      ;code for O
  35.      JSR  $FDED     !
  36.      LDA  #$C7      ;code for G
  37.      JSR  #$FDED    &
  38.      LDA  #$8D      ;carriage return
  39.      JSR  #$FDED    
  40. B     The hex codes for these characters can be found on page 7 of 
  41. the REFERENCE MANUAL.
  42. ?     A more elaborate example shown here includes prompting to B
  43. @ask the user which file is to be loaded.  This routine uses the A
  44. ?GETLN routine (see pages 33 and 62 of the REFERENCE MANUAL) to C
  45. Aget the prompted file name.  This name, stored in locations $200 >
  46. to $300, must be relocated before the output routine starts.
  47. 9000:  LDY  #$01    ;send out a "NAME?"
  48. 9002:  LDX  #$06    ;prompt
  49. 9004:  LDA  $90F0,Y 
  50. 9007:  JSR  $FDED   ;via COUT
  51. 900A:  INY
  52. 900B:  DEX)
  53. 900C:  BNE  $9004   ;get next character
  54. 900E:  JSR  $FD6F   ;GETLN1 routine
  55. 9011:  TXA
  56. 9012:  TAY(
  57. 9013:  LDA  $0200,Y ;relocate filename 
  58. 9016:  STA  $9098,Y ;to $9098-
  59. 9019:  DEY)
  60. 901A:  BNE  $9013   ;get next character
  61. 901C:  LDA  $0200
  62. 901F:  STA  $9098
  63. 9022:  CLC
  64. 9023:  TXA
  65. 9024:  ADC  #$07
  66. 9026:  TAX
  67. 9027:  LDY  #$01)
  68. 9029:  LDA  $9090,Y ;load "BLOAD file-"(
  69. 902C:  JSR  $FDED   ;send out via COUT
  70. 902F:  INY
  71. 9030:  DEX
  72. 9031:  BNE  $9029   "
  73. 9033:  LDA  #$8D    ;return code#
  74. 9035:  JSR  $FDED   ;through COUT
  75. 9038:  RTS
  76. Character storage:
  77. 9091:  84           ;control-D char%
  78. 9092:  C2           ;    B     char%
  79. 9093:  CC           ;    L     char%
  80. 9094:  CF           ;    O     char%
  81. 9095:  C1           ;    A     char%
  82. 9096:  C4           ;    D     char%
  83. 9097:  A0           ;    space char%
  84. 9098:  ?            ;filename chars$
  85. 9099:  ?            ; continued...
  86. 90A0:  ?
  87. 90F1:  CE           ;    N  char"
  88. 90F2:  C1           ;    A  char"
  89. 90F3:  CD           ;    M  char"
  90. 90F4:  C5           ;    E  char"
  91. 90F5:  BF           ;    ?  char"
  92. 90F6:  8D           ;return char
  93.